﻿using DBServer.Selenium.Extenium.Exception;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Selenium;

namespace DBServer.Selenium.Extenium.Fixtures
{
    public class ImageCellFixture : GridFixture
    {
        private readonly int _row;
        private readonly int _column;

        public ImageCellFixture(ISelenium driver, string name, int row, int column)
            : base(driver, name)
        {
            _row = row;
            _column = column;
        }

        public ImageCellFixture RequireUrlContains(string url)
        {
            var command =
                " window.Ext.fly( " +
                Path.Eval() + ".getView().getCell(" + _row + ", " + _column + ")" +
                " ).child('img').dom.src;";
            var eval = SafeExec(command);
            if (!eval.Contains(url))
            {
                throw new ExteniumException("Image url at row: " + _row + " and column: " + _column + " does not contain: " + url);
            }
            return this;
        }
        
    }
}